/**
 * 正则验证
 * 大写字母开头  驼峰命名法
 */

//去除前后空格
export const trim = (str) => {
    return str.replace(/(^\s*)|(\s*$)/g, "")
}
//验证密码的正确性
export const vaildPassword = (passWord) => {
    if( process.env.NODE_ENV === "development"){
        return true
    }
    return /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()\-_=+{}|;:,<.>/?]).{8,24}$/.test(passWord)
}
//验证电话号码的正确性
export const vaildPhoneNumber = (phone) => {
    
    return /^(?:(?:\+|00)86)?1[3-9]\d{9}$/.test(phone)
}

//验证邮箱的正确性
export const vaildEmail = (email) => {
    return /^([a-zA-Z\d])((\w|-)+\.?)+@([a-zA-Z\d]+\.)+[a-zA-Z]{2,6}$/.test(email)
}

//验证身份证号码的正确性
export const vaildCard = (card) => {
    return /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/.test(card)
}

/**
 * 判断是否为数组
 * @param {*} array
 */
export const isArray = (array) => {
    return Object.prototype.toString.call(array) === '[object Array]';
};
/**
 * 判断是否为对象
 * @param {*} object
 */
export const isObject = (object) => {
    return Object.prototype.toString.call(object) === '[object Object]';
};

/**
 * 判断是否为空对象
 * @param {*} object 源对象
 */
export const isEmptyObject = (object) => {
    return Object.keys(object).length === 0;
};
/**
 * 判断是否为空
 * @param {*} object 源对象
 */
export const isEmpty = (value) => {
    if (isArray(value)) {
        return value.length === 0;
    }
    if (isObject(value)) {
        return isEmptyObject(value);
    }
    return !value;
};